<?php


function getCurrentMilis() {
    $mill_time = microtime();
    $timeInfo = explode(' ', $mill_time);
    $milis_time = sprintf('%d%03d',$timeInfo[1],$timeInfo[0] * 1000);

    return $time;
}


function GetBaiduUrl( $salt, $q, $from, $to ) {
    $AppId = '20220328001146841';
    $key = 'lsOwRlhSqpyGyvt9fadl';
    $url = 'https://fanyi-api.baidu.com/api/trans/vip/translate?q='.$q
    .'&from='.$from
    .'&to='.$to
    .'&appid='.$AppId
    .'&salt='.$salt;

    $sign = md5($AppId.$q.$salt.$key);

    $url = $url.'&sign='.$sign;

    return array(
        'url' => $url,
        'sign' => $sign,
        'appid' => $AppId
    );
}

function BaiduToZh( $salt, $q ){
    $from = 'en';
    $to = 'zh';
    return GetBaiduUrl( $salt, $q, $from, $to );
}

function BaiduToEn( $salt, $q ){
    $from  = 'zh';
    $to = 'en';
    return GetBaiduUrl( $salt, $q, $from, $to );
}

function array_pop_key($arr, $value){
    // echo json_encode([a=>$arr, b=>$value]);
    $index = array_search($value, $arr);

    if($index != 0) array_splice($arr, $index, 1);

    // echo json_encode($arr);
    return $arr;
}

function makeSymbol(){
    #----设置时区
    date_default_timezone_set("PRC");
    // return md5(time() . mt_rand(1,1000000));
    return (time() . mt_rand(1,999));
}

?>